<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>

	<link href="../style/authority/common_style.css" rel="stylesheet" type="text/css">

	<link rel="stylesheet" href="../style/bootstrap.min.css" />
	<script type="text/javascript" src="../scripts/bootstrap.min.js" ></script>
	<title>信息管理系统</title>

</head>
<body>

<div id="main">
	<div>
		<div align="left" style="background-color: #E7E7E7;"><a id="dela"></a> <span style="color: red;" id="del" class="glyphicon glyphicon-remove" ></span>&nbsp;<span style="color: black;">删除</span>&nbsp;&nbsp;
			<span id="read" class="glyphicon glyphicon-ok" style="color: #0099CC;"></span><span style="color: #990000">&nbsp;标示已读</span></div>
	</div>
	<div>
		<table class="table table-bordered">
			<thead>
			<tr>

				<th class="text-center">消息类型</th>
				<th class="text-center">内容</th>
				<th class="text-center">发送者</th>
				<th class="text-center">发送时间</th>
				<th class="text-center">是否阅读</th>
			</tr>
			</thead>
			<tbody>
			<tr th:each="p:${pu.dataS}">
				<td style="display: none" id="id" th:text="${p.message.id}"></td>
				<td th:text="${p.message.type}">Bangalore</td>
				<td th:text="${p.message.content}">560001</td>
				<td th:text="${p.user.name}">wsef</td>
				<td th:text="${#dates.format(p.message.sendtime,'yyyy年MM月dd日 HH时mm分ss秒')}">wsef</td>
				<td class="d" th:if="${p.message.isread==0}" >未阅读</td>
				<td class="d" th:if="${p.message.isread==1}">已阅读</td>
			</tr>

			</tbody>
		</table>
		<div class="ui_tb_h30">
			<div class="ui_flt" style="height: 30px; line-height: 30px;">
				共有
				<span class="ui_txt_bold04" th:text="${pu.totalCount}">90</span> 条记录，当前第
				<span class="ui_txt_bold04" th:text="${pu.currentPage}"></span> /<span th:text="${pu.pageCount}"></span>页
			</div>
			<div class="ui_frt">
				<!--    如果是第一页，则只显示下一页、尾页 -->
				<a th:href="@{/MyMessge(page=1)}"><input type="button" value="首页" class="ui_input_btn01" /></a>
				<a th:if="${pu.currentPage==1}"><input type="button" value="上一页" class="ui_input_btn01" /></a>
				<a th:if="${pu.currentPage!=1}" th:href="@{/MyMessge(page=${pu.currentPage-1})}"><input type="button" value="上一页" class="ui_input_btn01" /></a>

				<a th:if="${pu.currentPage==pu.pageCount}"><input type="button" value="下一页" class="ui_input_btn01" onclick="jumpNormalPage(2);" /></a>
				<a th:if="${pu.currentPage!=pu.pageCount}" th:href="@{/MyMessge(page=${pu.currentPage+1})}"><input type="button" value="下一页" class="ui_input_btn01" onclick="jumpNormalPage(2);" /></a>
				<a th:href="@{/MyMessge(page=${pu.pageCount})}"><input type="button" value="尾页" class="ui_input_btn01" onclick="jumpNormalPage(9);" /></a>
				<!--     如果是最后一页，则只显示首页、上一页 -->
				<input type="hidden" th:value="${pu.pageCount}" id="pageCount"/>
				转到第<input type="text" id="pp"  class="ui_input_txt01" />页
				<input type="button" class="ui_input_btn01" value="跳转" onclick="pp()" /><a id="a2"></a>
			</div>
		</div>

	</div>

</div>



</body>
</html>
<script>


    function pp() {
        var pp=$("#pp").val();
        var pageCount=$("#pageCount").val();
        if(!(pp.trim())){
            alert("跳转框不能为空哦")
        }else if(pp>pageCount){
            alert("跳转框不能超出分页最大值哦")
        }else if(pp<=0){
            alert("跳转框不能小于1哦")
        }else{
            $("#a2").attr("href","/MyMessge?page="+pp)
            document.getElementById("a2").click();
        }



    }







    $(function () {
        $("#del").prop("onclick","")
        $("#read").prop("onclick","");
        $("#del").prop("style","color:burlywood")
        $("#read").prop("style","color:burlywood");
    })

    $("tr").click(function () {
        $(this).prop("class","active").siblings().removeClass("active")
        var id=$("[class='active']").children("#id").text();
        $("#del").attr("onclick","del("+id+")")
        $("#read").attr("onclick","read("+id+")");
        $("#del").prop("style","color:red")
        $("#read").prop("style","color:blue");

    })

    function del(data) {

        $("#dela").attr("href","/messagedel?id="+data)
        document.getElementById("dela").click();
    }



    function read(data) {

        var url="/messageread"
        var params="id="+data;
        $.post(url,params,function (date) {

            var read=$("[class='active']").children("[class='d']").text(date);
        })

    }

</script>
